package app.system.service.impl;

import app.system.entity.MusicMusicLisit;
import app.system.entity.Page;
import app.system.entity.SysMusicList;
import app.system.mapper.MusicMusicLisitMapper;
import app.system.mapper.SysMusicListMapper;
import app.system.service.SysMusicListService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SysMusicListServiceimpl implements SysMusicListService {
    @Autowired
    private SysMusicListMapper musicListMapper;
    @Autowired
    private MusicMusicLisitMapper musicMusicLisitMapper;
    @Override
    public int saveMusicList(SysMusicList sysMusicList) {
        return musicListMapper.saveMusicList(sysMusicList);
    }

    @Override
    public PageInfo<SysMusicList> selectMusicListByTage(SysMusicList sysMusicList, Page page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        return new PageInfo<SysMusicList>(musicListMapper.selectMusicListByTage(sysMusicList));
    }

    @Override
    public List<SysMusicList> getMusicListAll() {
        return musicListMapper.getMusicListAll();
    }

    @Override
    public int updateMusicListByTage(SysMusicList sysMusicList) {
        return musicListMapper.updateMusicListByTage(sysMusicList);
    }

    @Override
    public SysMusicList selectSysMusicListById(String list_id) {
        return musicListMapper.selectSysMusicListById(list_id);
    }

    @Override
    public int deleteSysMusicList(String list_id) {
        MusicMusicLisit musicMusicLisit = new MusicMusicLisit();
        musicMusicLisit.setMusiclist_id(list_id);
        musicMusicLisitMapper.deleteMusicMusicLisit(musicMusicLisit);
        if (musicListMapper.deleteSysMusicList(list_id)>0){
            return 1;
        }else {
            return -1;
        }
    }

    @Override
    public List<SysMusicList> selectMusicListByLike(String musicListName) {
        return musicListMapper.selectMusicListByLike(musicListName);
    }

    @Override
    public int selectMusicCount(String list_type) {
        return musicListMapper.selectMusicCount(list_type);
    }
}
